function getAgentLevel(levelId) {
    $.ajax({
        cache : true,
        type : "GET",
        url : ctx+"/agent/agentLevel/agentLevelDOList",
        data : $('#signupForm').serialize(),// 你的formid
        async : false,
        error : function(request) {
            parent.layer.alert("Connection error");
        },
        success : function(data) {
            var itemList = data.data;
            var htmlText ="";
            for (var i in itemList){
                var item = itemList[i];
                if (item.levelId == levelId){
                    htmlText += "<option selected='selected' value='"+item.levelId+"'> "+item.levelName+" </option>"
                }else{
                    htmlText += "<option value='"+item.levelId+"'> "+item.levelName+" </option>"
                }
            }
            $("#levelId").append(htmlText);
        }
    });
}

function getSupplierTypeByUpdate(typeId) {
    $.ajax({
        cache : true,
        type : "GET",
        url : ctx+"/supplier/supplierType/getSupplierList",
        data : $('#signupForm').serialize(),// 你的formid
        async : false,
        error : function(request) {
            parent.layer.alert("Connection error");
        },
        success : function(data) {

            console.log(data)
            var itemList = data.data;
            var htmlText ="";
            for (var i in itemList){
                var item = itemList[i];
                if (item.supplierTypeId == typeId){
                    htmlText += "<option selected = 'selected' value='"+item.supplierTypeId+"'> "+item.typeName+" </option>"
                }else{
                    htmlText += "<option value='"+item.supplierTypeId+"'> "+item.typeName+" </option>"
                }

            }

            $("#supplierTypeId").append(htmlText);
        }
    });
}

function getSupplierByUpdate(supplierId) {
    $.ajax({
        cache : true,
        type : "GET",
        url : ctx+"/supplier/supplier/getSupplierList",
        // data : $('#signupForm').serialize(),// 你的formid
        async : false,
        error : function(request) {
            parent.layer.alert("Connection error");
        },
        success : function(data) {
            var itemList = data.data;
            var htmlText ="";
            for (var i in itemList){
                var item = itemList[i];
                if (item.supplierId == supplierId){
                    htmlText += "<option selected='selected' value='"+item.supplierId+"'> "+item.supplierName+" </option>"
                }else{
                    htmlText += "<option value='"+item.supplierId+"'> "+item.supplierName+" </option>"
                }
            }
            $("#supplierId").append(htmlText);
        }
    });
}

function getMaterialByUpdate(materialId) {
    $.ajax({
        cache : true,
        type : "GET",
        url : ctx+"material/material/getMaterialList",
        // data : $('#signupForm').serialize(),// 你的formid
        async : false,
        error : function(request) {
            parent.layer.alert("Connection error");
        },
        success : function(data) {
            var itemList = data.data;
            var htmlText ="";
            for (var i in itemList){
                var item = itemList[i];
                if (item.materialId == materialId){
                    htmlText += "<option selected='selected' value='"+item.materialId+"'> "+item.materialName+" </option>"
                }else{
                    htmlText += "<option value='"+item.materialId+"'> "+item.materialName+" </option>"
                }
            }
            $("#materialId").append(htmlText);
        }
    });
}

function getTraceabilityFile(traceabilityFileId) {
    $.ajax({
        cache : true,
        type : "GET",
        url : ctx+"/trace/traceabilityFile/all",
        // data : $('#signupForm').serialize(),// 你的formid
        async : false,
        error : function(request) {
            parent.layer.alert("Connection error");
        },
        success : function(data) {
            var itemList = data.data;
            var htmlText ="";
            for (var i in itemList){
                var item = itemList[i];
                if (item.traceabilityFileId == traceabilityFileId){
                    htmlText += "<option selected='selected' value='"+item.traceabilityFileId+"'> "+item.traceabilityFileName+" </option>"
                }else{
                    htmlText += "<option value='"+item.traceabilityFileId+"'> "+item.traceabilityFileName+" </option>"
                }
            }
            $("#traceabilityFileId").append(htmlText);
        }
    });
}


function getAttr(attrId) {
    $.ajax({
        cache : true,
        type : "GET",
        url : ctx+"/attr/attr/all",
        // data : $('#signupForm').serialize(),// 你的formid
        async : false,
        error : function(request) {
            parent.layer.alert("Connection error");
        },
        success : function(data) {
            var itemList = data.data;
            var htmlText ="";
            for (var i in itemList){
                var item = itemList[i];
                if (item.attrId == attrId){
                    htmlText += "<option selected='selected' value='"+item.attrId+"'> "+item.attrName+" </option>"
                }else{
                    htmlText += "<option value='"+item.attrId+"'> "+item.attrName+" </option>"
                }
            }
            $("#attrId").append(htmlText);
        }
    });
}

function getReport(reportId,flag) {
    $.ajax({
        cache : true,
        type : "GET",
        url : ctx+"/report/report/all",
        // data : $('#signupForm').serialize(),// 你的formid
        async : false,
        error : function(request) {
            parent.layer.alert("Connection error");
        },
        success : function(data) {
            var itemList = data.data;
            var htmlText ="";
            if (flag){
                htmlText += "<option value=''> 请选择 </option>"
            }
            for (var i in itemList){
                var item = itemList[i];
                if (item.reportId == reportId){
                    htmlText += "<option selected='selected' value='"+item.reportId+"'> "+item.reportName+" </option>"
                }else{
                    htmlText += "<option value='"+item.reportId+"'> "+item.reportName+" </option>"
                }
            }
            $("#reportId").append(htmlText);
        }
    });
}

function getPurchase(purchaseId,flag) {
    $.ajax({
        cache : true,
        type : "GET",
        url : ctx+"/material/purchase/all",
        // data : $('#signupForm').serialize(),// 你的formid
        async : false,
        error : function(request) {
            parent.layer.alert("Connection error");
        },
        success : function(data) {
            var itemList = data.data;
            var htmlText ="";
            if (flag){
                htmlText += "<option value=''> 请选择 </option>"
            }
            for (var i in itemList){
                var item = itemList[i];
                if (item.purchaseId == purchaseId){
                    htmlText += "<option selected='selected' value='"+item.purchaseId+"'> "+item.purchaseNo+" </option>"
                }else{
                    htmlText += "<option value='"+item.purchaseId+"'> "+item.purchaseNo+" </option>"
                }
            }
            $("#purchaseId").append(htmlText);
        }
    });
}

function getProduct(productId) {
    $.ajax({
        cache : true,
        type : "GET",
        url : ctx+"/product/product/all",
        // data : $('#signupForm').serialize(),// 你的formid
        async : false,
        error : function(request) {
            parent.layer.alert("Connection error");
        },
        success : function(data) {
            var itemList = data.data;
            var htmlText ="";
            for (var i in itemList){
                var item = itemList[i];
                if (item.productId == productId){
                    htmlText += "<option selected='selected' value='"+item.productId+"'> "+item.productName+" </option>"
                }else{
                    htmlText += "<option value='"+item.productId+"'> "+item.productName+" </option>"
                }
            }
            $("#productId").append(htmlText);
        }
    });
}

function getCheckMechanismByUpdate(checkMechanismId) {

    $.ajax({
        cache : true,
        type : "GET",
        url : ctx +"/check/checkMechanism/all",
        // data : $('#signupForm').serialize(),// 你的formid
        async : false,
        error : function(request) {
            parent.layer.alert("Connection error");
        },
        success : function(data) {
            var itemList = data.data;
            var htmlText ="";
            for (var i in itemList){
                var item = itemList[i];
                if (item.checkMechanismId == checkMechanismId){
                    htmlText += "<option selected='selected' value='"+item.checkMechanismId+"'> "+item.checkMechanismName+" </option>"
                }else{
                    htmlText += "<option value='"+item.checkMechanismId+"'> "+item.checkMechanismName+" </option>"
                }
            }
            $("#checkMechanismId").append(htmlText);
        }
    });
}

function getCheckTypeByUpdate(checkTypeId) {

    $.ajax({
        cache : true,
        type : "GET",
        url : ctx +"/check/checkType/all",
        // data : $('#signupForm').serialize(),// 你的formid
        async : false,
        error : function(request) {
            parent.layer.alert("Connection error");
        },
        success : function(data) {
            var itemList = data.data;
            var htmlText ="";
            for (var i in itemList){
                var item = itemList[i];
                if (item.checkTypeId == checkTypeId){
                    htmlText += "<option selected='selected' value='"+item.checkTypeId+"'> "+item.checkTypeName+" </option>"
                }else{
                    htmlText += "<option value='"+item.checkTypeId+"'> "+item.checkTypeName+" </option>"
                }
            }
            $("#checkTypeId").append(htmlText);
        }
    });
}

 function getProcedures(procedureId){
    $.ajax({
        cache : true,
        url : ctx + "/procedures/procedures/all",
        type : 'GET',
        data : $('#signupForm').serialize(),
        async : false,
        error : function(request) {
            parent.layer.alert("Connection error");
        },
        success : function(data) {
            console.log(data)
            var itemList = data.data;
            var htmlText = "";
            for (var i in itemList) {
                var item = itemList[i];
                if (item.procedureId == procedureId) {
                    htmlText += "<option selected = 'selected' value='" + item.procedureId + "'> " + item.name + " </option>"
                } else {
                    htmlText += "<option value='" + item.procedureId + "'> " + item.name + " </option>"
                }

            }

            $("#procedureId").append(htmlText);

        }
         }
    );



 }
